package ahblue.cn.tanzi.model.home;

import android.content.Context;
import android.widget.Toast;

import ahblue.cn.tanzi.data.source.ApiCallback;
import ahblue.cn.tanzi.data.source.RemoteRepository;
import ahblue.cn.tanzi.model.user.LoginResultModel;
import ahblue.cn.tanzi.util.PinkJSON;

/**
 * @author pink-jackstraw
 * @date 2018/11/19
 * @describe 视频详情
 */
public class VideoDetailModel {

    public String id;
    public String title;
    public String file;
    public String user_id;
    public String describe;
    public int is_fabulous =1;
    public int is_collection =1;
    public String add_time;
    public UserDataBean user_data;

    public static class UserDataBean {
        public String member_id;
        public String member_name;
        public String member_avatar;
    }

    public static void getDetail(final Context context, String type, final VideoDetailResult mListener) {
        RemoteRepository repo = RemoteRepository.getsInstance();
        repo.getDetail(type, new ApiCallback<VideoDetailModel>() {
            @Override
            public void onSuccess(VideoDetailModel data) {
                LoginResultModel.saveUserInfo(context, PinkJSON.toJSON(data).toString());
                if (null != mListener) {
                    mListener.conver(data);
                }
            }

            @Override
            public void onFailed(String errorMsg) {
                Toast.makeText(context, errorMsg, Toast.LENGTH_LONG).show();
                if (null != mListener) {
                    mListener.conver(null);
                }
            }
        });
    }

    public interface VideoDetailResult {
        void conver(VideoDetailModel model);
    }


}
